from flask import Blueprint,jsonify,request
from flask import current_app,render_template
from sqlalchemy import *
from job.models import CateWC,Job
from job import db
ind = Blueprint("ind",__name__)

@ind.route("/")
def index():
    # 改成ajax，在获取地图数据时计算
    # 
    # cate2_2 = db.session.execute(
    #     "select * from(select cate2,city,avg(salary)as avg_sal from job group by cate2,city)job order by avg_sal DESC limit 500").fetchall()  ##计算机类工作top图cate2
    # cate1_num = db.session.execute("select * from(select cate1,sum(num) as num from job group by cate1)job order by num DESC limit 10").fetchall()
    # cate2_num = db.session.execute("select * from(select cate2,sum(num) as num from job group by cate2)job order by num DESC limit 11").fetchall()
    return render_template("ind.html")

@ind.route('/province')
def province():
    # result = db.session.execute("select province,sum(num) from job group by province limit 50").fetchall()
    # province=[]
    # num=[]
    # province_num =[]
    # for i in range(len(result)):
    #     json={}
    #     json['name']=result[i][0]
    #     json['value']=int(result[i][1])
    #     province_num.append(json)
    # for p in ["新疆","西藏","青海","甘肃","内蒙古","宁夏","山西","河北","贵州","海南","台湾"]:
    #     json = {}
    #     json['name'] = p
    #     json['value'] = 0
    #     province_num.append(json)
    #     # province.append(result[i][0])
    #     # num.append(int(result[i][1]))
    # print(province_num)
    # return jsonify(province_num)
    return jsonify([{"name":"\u4e0a\u6d77","value":273057},{"name":"\u4e91\u5357","value":15310},{"name":"\u5317\u4eac","value":109966},{"name":"\u5409\u6797","value":5347},{"name":"\u56db\u5ddd","value":87619},{"name":"\u5929\u6d25","value":12474},{"name":"\u5b89\u5fbd","value":35119},{"name":"\u5c71\u4e1c","value":35401},{"name":"\u5e7f\u4e1c","value":573097},{"name":"\u5e7f\u897f","value":5235},{"name":"\u6c5f\u82cf","value":268222},{"name":"\u6c5f\u897f","value":10893},{"name":"\u6cb3\u5317","value":4307},{"name":"\u6cb3\u5357","value":20280},{"name":"\u6d59\u6c5f","value":158581},{"name":"\u6e56\u5317","value":74829},{"name":"\u6e56\u5357","value":38369},{"name":"\u798f\u5efa","value":30323},{"name":"\u8d35\u5dde","value":3095},{"name":"\u8fbd\u5b81","value":28494},{"name":"\u91cd\u5e86","value":30119},{"name":"\u9655\u897f","value":50497},{"name":"\u9ed1\u9f99\u6c5f","value":10463},{"name":"\u65b0\u7586","value":0},{"name":"\u897f\u85cf","value":0},{"name":"\u9752\u6d77","value":0},{"name":"\u7518\u8083","value":0},{"name":"\u5185\u8499\u53e4","value":0},{"name":"\u5b81\u590f","value":0},{"name":"\u5c71\u897f","value":0},{"name":"\u6cb3\u5317","value":0},{"name":"\u8d35\u5dde","value":0},{"name":"\u6d77\u5357","value":0},{"name":"\u53f0\u6e7e","value":0}])

@ind.route('/city_num')
def city_num():

    city_num = db.session.execute("select city,sum(num) from job group by city").fetchall()  ##城市招聘人数
    jihe=[]
    # 工作的总数
    jobsum = 0
    for i in range(len(city_num)):
        json = {}
        json['name']=city_num[i][0]
        json['value']=int(city_num[i][1])
        # 累计，就是总数了
        jobsum+=int(city_num[i][1])
        jihe.append(json)
    return jsonify({
        'jihe':jihe,
        'jobsum':jobsum
    })

@ind.route('/city_num1')
def city_num1():

    city_num = db.session.execute("select city,sum(num) from job group by city").fetchall()  ##城市招聘人数
    jihe=[]
    # 工作的总数
    jobsum = 0
    for i in range(len(city_num)):
        json = {}
        json['name']=city_num[i][0]+'市'
        json['value']=int(city_num[i][1])
        # 累计，就是总数了
        jobsum+=int(city_num[i][1])
        jihe.append(json)
    return jsonify({
        'jihe':jihe,
        'jobsum':jobsum
    })

@ind.route('/exp')
def exp():
    result = db.session.execute(
        "select * from(select exp,(sum(salary)/count(*)) as avg from job group by exp)job order by avg DESC ")  ##经验与月薪
    exp=[]
    salary=[]
    for i in result:
        exp.append(i[0])
        salary.append(int(i[1]))
    return jsonify({
        "exp":exp,
        "salary":salary
    })

# 每种职业的招聘人数
@ind.route('/cate2_num')
def cate2_num():
    result = db.session.execute(
        "select * from(select cate2,count(*) as num from job group by cate2) job order by num DESC limit 11").fetchall()  ##计算机类工作top图cate2
    cate2=[]
    num=[]
    for i in result:
        if(i[0]=="其他"):
            pass
        else :
            cate2.append(i[0])
            num.append(int(i[1]))
    return jsonify({
        "cate2":cate2,
        "num":num
    })

# 学历要求
@ind.route('/edu')
def edu():
    result = db.session.execute("select edu,count(*) from job group by edu").fetchall()  ##学历要求
    edu=[]
    for i in result:
        json={}
        json['name']=i[0]
        json['value']=i[1]
        edu.append(json)
    return jsonify(edu)

# 经验要求
@ind.route('/exp_num')
def exp_num():
    result = db.session.execute("select exp,count(*) from job group by exp").fetchall()  ##经验占比
    exp=[]
    for i in result:
        json={}
        json['name']=i[0]
        json['value']=i[1]
        exp.append(json)
    return jsonify(exp)

@ind.route('/cate1_num')
def cate1_num():
    result = db.session.execute("select cate1,sum(num) n from job group by cate1 order by n").fetchall()
    cate1 = []
    num = []
    for i in result:
        cate1.append(i[0])
        num.append(int(i[1]))
    return jsonify({
        "cate1":cate1,
        "num":num
    })
# 各城市招聘数量和平均工资
@ind.route('/city_data')
def city_data():
    city_num = db.session.execute("select province,city,sum(num),avg(salary)  from job group by province,city").fetchall()  ##城市招聘人数
    jihe=[]
    for i in range(len(city_num)):
        json = {}
        json['name']=city_num[i][1]
        json['num']=int(city_num[i][2])
        json['salary']=int(city_num[i][3])
        jihe.append(json)
    # 按城市和工资排序
    return jsonify(jihe)

# 查询所有分类
@ind.route('/cates_num')
def cates_num():
#     result = db.session.execute(" select cate1,cate2,sum(num) num from job group by cate1,cate2 order by cate1 ,num desc;")
#     '''
# mysql> select cate1,cate2,sum(num) num from job group by cate1,cate2 order by cate1,num;
# +--------------------+----------------------------------------+--------+
# | cate1              | cate2                                  | num    |
# +--------------------+----------------------------------------+--------+
# | 产品               | 用户产品经理                           |      5 |
# | 产品               | 移动产品经理                           |     98 |
# | 产品               | 产品总监                               |    288 |
#     '''
#     result = result.fetchall()
#     cates = {}
#
#     cates  = {}
#     # 一级分类个数
#     cate2_default =  []
#     for row in result:
#         cate1 = row['cate1']
#         cate2 = row['cate2']
#         num = int(row['num'])
#
#         # 跳过其他
#         if cate2=="其他":
#             continue
#
#         # 有就直接接
#         if cate1 not in cates.keys():
#             cates[cate1]=[]
#
#         cates[cate1].append({
#             'cate2':cate2,
#             'num':num
#         })
#         cate2_default.append({
#             "cate2":cate2,
#             "num":num
#         })
#
#     # 一级分类数量
#     cate1_num = []
#     for cate1,cate2 in cates.items():
#         s = 0
#         for item in cate2:
#             s+=item['num']
#         cate1_num.append({
#             "cate1":cate1,
#             "num":s
#         })
#     # 二级分类top10
#     cate2_default.sort(key=lambda x:x['num'],reverse=True)
#     cate2_default = cate2_default[0:11]
#
#     cate1_num.sort(key=lambda k: k['num'],reverse=True)
#     print(cates)
#     print(cate2_default)
#     print(cate1_num)
#     # 二级分类默认显示Top 的
#     cates['全部'] = cate2_default
#     data = {
#         'cate2_num':cates,
#         'cate1_num':cate1_num
#     }
#     return jsonify(data)

    return jsonify({"cate1_num":[{"cate1":"\u6d4b\u8bd5","num":325511},{"cate1":"\u6570\u636e","num":270495},{"cate1":"\u540e\u7aef\u5f00\u53d1","num":270082},{"cate1":"\u8fd0\u7ef4/\u6280\u672f\u652f\u6301","num":121245},{"cate1":"\u7535\u5b50/\u7535\u5668/\u4eea\u5668\u4eea\u8868","num":107295},{"cate1":"\u534a\u5bfc\u4f53/\u82af\u7247","num":41817},{"cate1":"\u6e38\u620f","num":28526},{"cate1":"\u901a\u4fe1\u6280\u672f\u5f00\u53d1\u53ca\u5e94\u7528","num":25285},{"cate1":"\u8bbe\u8ba1","num":24070},{"cate1":"\u6280\u672f\u7ba1\u7406","num":22956},{"cate1":"\u4ea7\u54c1","num":21301},{"cate1":"\u524d\u7aef\u5f00\u53d1","num":13083},{"cate1":"\u4eba\u5de5\u667a\u80fd","num":11625},{"cate1":"\u79fb\u52a8\u5f00\u53d1","num":5707}],"cate2_num":{"\u4ea7\u54c1":[{"cate2":"\u4ea7\u54c1\u4e13\u5458","num":6911},{"cate2":"\u4ea7\u54c1\u7ecf\u7406/\u4e3b\u7ba1","num":5966},{"cate2":"\u4e92\u8054\u7f51\u4ea7\u54c1\u7ecf\u7406","num":5072},{"cate2":"\u9700\u6c42\u5de5\u7a0b\u5e08","num":1110},{"cate2":"\u7535\u5546\u4ea7\u54c1\u7ecf\u7406","num":784},{"cate2":"\u4ea7\u54c1\u52a9\u7406","num":736},{"cate2":"\u79fb\u52a8\u4ea7\u54c1\u7ecf\u7406","num":389},{"cate2":"\u4ea7\u54c1\u603b\u76d1","num":321},{"cate2":"\u7528\u6237\u4ea7\u54c1\u7ecf\u7406","num":12}],"\u4eba\u5de5\u667a\u80fd":[{"cate2":"\u7b97\u6cd5\u5de5\u7a0b\u5e08","num":8377},{"cate2":"\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","num":979},{"cate2":"\u641c\u7d22\u7b97\u6cd5\u5de5\u7a0b\u5e08","num":869},{"cate2":"\u56fe\u50cf\u7b97\u6cd5\u5de5\u7a0b\u5e08","num":584},{"cate2":"\u673a\u5668\u89c6\u89c9\u5de5\u7a0b\u5e08","num":559},{"cate2":"\u673a\u5668\u5b66\u4e60\u5de5\u7a0b\u5e08","num":163},{"cate2":"\u56fe\u50cf\u5904\u7406\u5de5\u7a0b\u5e08","num":94}],"\u5168\u90e8":[{"cate2":"\u6570\u636e\u5206\u6790\u5e08","num":268112},{"cate2":"\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":167533},{"cate2":"\u8f6f\u4ef6\u5de5\u7a0b\u5e08","num":163166},{"cate2":"\u6d4b\u8bd5\u5f00\u53d1","num":89335},{"cate2":"\u8fd0\u7ef4\u5de5\u7a0b\u5e08","num":54848},{"cate2":"\u9ad8\u7ea7\u8f6f\u4ef6\u5de5\u7a0b\u5e08","num":51799},{"cate2":"\u6d4b\u8bd5\u4e3b\u7ba1","num":36685},{"cate2":"\u7535\u5b50\u9500\u552e\u5de5\u7a0b\u5e08","num":31373},{"cate2":"\u6280\u672f\u652f\u6301/\u7ef4\u62a4\u5de5\u7a0b\u5e08","num":27849},{"cate2":"\u7535\u6c14\u5de5\u7a0b\u5e08/\u6280\u672f\u5458","num":25962},{"cate2":"\u7535\u5b50\u5de5\u827a\u5de5\u7a0b\u5e08","num":17799}],"\u524d\u7aef\u5f00\u53d1":[{"cate2":"Web\u524d\u7aef\u5f00\u53d1","num":12241},{"cate2":"HTML5\u5f00\u53d1\u5de5\u7a0b\u5e08","num":842}],"\u534a\u5bfc\u4f53/\u82af\u7247":[{"cate2":"\u534a\u5bfc\u4f53\u5668\u4ef6\u5de5\u7a0b\u5e08","num":9343},{"cate2":"\u534a\u5bfc\u4f53\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":5188},{"cate2":"\u96c6\u6210\u7535\u8defIC\u8bbe\u8ba1/\u5e94\u7528\u5de5\u7a0b\u5e08","num":4631},{"cate2":"\u534a\u5bfc\u4f53\u6587\u6863\u5de5\u7a0b\u5e08","num":4255},{"cate2":"\u534a\u5bfc\u4f53\u5de5\u827a\u5de5\u7a0b\u5e08","num":3597},{"cate2":"FPGA\u5f00\u53d1\u5de5\u7a0b\u5e08","num":3192},{"cate2":"\u5c01\u88c5\u5de5\u7a0b\u5e08","num":2155},{"cate2":"\u534a\u5bfc\u4f53\u6280\u672f","num":1801},{"cate2":"FAE\u73b0\u573a\u5e94\u7528\u5de5\u7a0b\u5e08","num":1331},{"cate2":"\u7248\u56fe\u8bbe\u8ba1\u5de5\u7a0b\u5e08","num":1158},{"cate2":"EDA\u5de5\u7a0b\u5e08","num":848},{"cate2":"\u82af\u7247\u9500\u552e\u5de5\u7a0b\u5e08","num":774},{"cate2":"\u5931\u6548\u5206\u6790\u5de5\u7a0b\u5e08(FA)","num":751},{"cate2":"\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","num":713},{"cate2":"\u534a\u5bfc\u4f53\u8bbe\u5907\u5de5\u7a0b\u5e08","num":550},{"cate2":"\u6a21\u62df\u82af\u7247\u5de5\u7a0b\u5e08","num":432},{"cate2":"\u5c01\u88c5\u7814\u53d1\u5de5\u7a0b\u5e08","num":351},{"cate2":"\u82af\u7247\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":212},{"cate2":"IC\u9a8c\u8bc1\u5de5\u7a0b\u5e08","num":199},{"cate2":"\u5c04\u9891\u82af\u7247\u8bbe\u8ba1","num":99},{"cate2":"MEMS\u5de5\u7a0b\u5e08","num":61},{"cate2":"\u6a21\u62df\u7248\u56fe\u5de5\u7a0b\u5e08","num":54},{"cate2":"\u5de5\u827a\u6574\u5408\u5de5\u7a0b\u5e08(PIE)","num":50},{"cate2":"\u6570\u5b57\u524d\u7aef\u5de5\u7a0b\u5e08","num":49},{"cate2":"\u534a\u5bfc\u4f53\u4ea7\u54c1\u7ecf\u7406/\u4ea7\u54c1\u5de5\u7a0b\u5e08","num":18},{"cate2":"\u6570\u5b57\u540e\u7aef\u5de5\u7a0b\u5e08","num":5}],"\u540e\u7aef\u5f00\u53d1":[{"cate2":"\u8f6f\u4ef6\u5de5\u7a0b\u5e08","num":163166},{"cate2":"\u9ad8\u7ea7\u8f6f\u4ef6\u5de5\u7a0b\u5e08","num":51799},{"cate2":"Java\u5f00\u53d1\u5de5\u7a0b\u5e08","num":16688},{"cate2":"Hadoop\u5de5\u7a0b\u5e08","num":8468},{"cate2":"\u5927\u6570\u636e\u5f00\u53d1\u5de5\u7a0b\u5e08","num":5583},{"cate2":"\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","num":5317},{"cate2":"\u6280\u672f\u6587\u5458/\u52a9\u7406","num":4532},{"cate2":"C/C++\u5f00\u53d1\u5de5\u7a0b\u5e08","num":3435},{"cate2":"Go\u5f00\u53d1\u5de5\u7a0b\u5e08","num":3300},{"cate2":"ERP\u6280\u672f\u5f00\u53d1","num":2430},{"cate2":".NET\u5f00\u53d1\u5de5\u7a0b\u5e08","num":1286},{"cate2":"\u591a\u5a92\u4f53\u5f00\u53d1\u5de5\u7a0b\u5e08","num":1132},{"cate2":"PHP\u5f00\u53d1\u5de5\u7a0b\u5e08","num":697},{"cate2":"Ruby\u5f00\u53d1\u5de5\u7a0b\u5e08","num":661},{"cate2":"Python\u5f00\u53d1\u5de5\u7a0b\u5e08","num":567},{"cate2":"\u7cfb\u7edf\u5206\u6790\u5458","num":549},{"cate2":"\u722c\u866b\u5f00\u53d1\u5de5\u7a0b\u5e08","num":437},{"cate2":"\u6280\u672f\u6587\u6863\u5de5\u7a0b\u5e08","num":35}],"\u6280\u672f\u7ba1\u7406":[{"cate2":"\u9879\u76ee\u7ecf\u7406","num":15465},{"cate2":"\u9879\u76ee\u6267\u884c/\u534f\u8c03\u4eba\u5458","num":4432},{"cate2":"\u9879\u76ee\u4e3b\u7ba1","num":1455},{"cate2":"\u6280\u672f\u603b\u76d1/\u7ecf\u7406","num":1350},{"cate2":"\u9879\u76ee\u603b\u76d1","num":250},{"cate2":"\u9996\u5e2d\u6280\u672f\u6267\u884c\u5b98CTO/\u9996\u5e2d\u4fe1\u606f\u5b98CIO","num":4}],"\u6570\u636e":[{"cate2":"\u6570\u636e\u5206\u6790\u5e08","num":268112},{"cate2":"\u6570\u636e\u91c7\u96c6\u5de5\u7a0b\u5e08","num":1159},{"cate2":"ETL\u5f00\u53d1\u5de5\u7a0b\u5e08","num":426},{"cate2":"BI\u5de5\u7a0b\u5e08","num":390},{"cate2":"\u6570\u636e\u4ed3\u5e93\u5de5\u7a0b\u5e08","num":271},{"cate2":"\u6570\u636e\u5efa\u6a21\u5de5\u7a0b\u5e08","num":90},{"cate2":"\u6570\u636e\u6cbb\u7406\u5de5\u7a0b\u5e08","num":40},{"cate2":"\u6570\u636e\u5206\u6790\u7ecf\u7406/\u4e3b\u7ba1","num":7}],"\u6d4b\u8bd5":[{"cate2":"\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":167533},{"cate2":"\u6d4b\u8bd5\u5f00\u53d1","num":89335},{"cate2":"\u6d4b\u8bd5\u4e3b\u7ba1","num":36685},{"cate2":"\u6027\u80fd\u6d4b\u8bd5","num":8638},{"cate2":"\u8f6f\u4ef6\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":7987},{"cate2":"\u529f\u80fd\u6d4b\u8bd5","num":6210},{"cate2":"\u6d4b\u8bd5\u603b\u76d1","num":4387},{"cate2":"\u81ea\u52a8\u5316\u6d4b\u8bd5","num":2423},{"cate2":"\u6d4b\u8bd5\u7ecf\u7406","num":823},{"cate2":"\u7cfb\u7edf\u6d4b\u8bd5","num":610},{"cate2":"\u5b89\u5168\u6d4b\u8bd5","num":456},{"cate2":"\u79fb\u52a8\u7aef\u6d4b\u8bd5","num":253},{"cate2":"\u6807\u51c6\u5316\u5de5\u7a0b\u5e08","num":171}],"\u6e38\u620f":[{"cate2":"\u6e38\u620f\u89d2\u8272\u8bbe\u8ba1\u5e08","num":3916},{"cate2":"\u6e38\u620f\u7cfb\u7edf\u7b56\u5212","num":3842},{"cate2":"\u6e38\u620f\u6d4b\u8bd5","num":3022},{"cate2":"\u6e38\u620f\u5f00\u53d1\u5de5\u7a0b\u5e08","num":2567},{"cate2":"\u6e38\u620f\u52a8\u753b\u5e08","num":2495},{"cate2":"\u6e38\u620f\u6587\u6848\u7b56\u5212/\u5267\u60c5\u7b56\u5212","num":2433},{"cate2":"\u6e38\u620f\u539f\u753b\u5e08","num":1987},{"cate2":"\u6e38\u620f\u7b56\u5212\u5e08","num":1653},{"cate2":"\u6e38\u620f\u573a\u666f\u8bbe\u8ba1\u5e08","num":1570},{"cate2":"\u6e38\u620f\u7279\u6548\u8bbe\u8ba1\u5e08","num":1470},{"cate2":"Unity3d\u5f00\u53d1\u5de5\u7a0b\u5e08","num":710},{"cate2":"\u6e38\u620f\u8fd0\u8425","num":582},{"cate2":"\u6e38\u620f\u52a8\u4f5c\u8bbe\u8ba1\u5e08","num":507},{"cate2":"\u6e38\u620f\u5ba2\u6237\u7aef\u5f00\u53d1\u5de5\u7a0b\u5e08","num":457},{"cate2":"\u6e38\u620f\u754c\u9762\u8bbe\u8ba1\u5e08","num":457},{"cate2":"\u6e38\u620f\u6570\u503c\u7b56\u5212","num":346},{"cate2":"UE4\u7279\u6548\u5e08","num":141},{"cate2":"\u6e38\u620f\u5173\u5361\u7b56\u5212","num":100},{"cate2":"\u6e38\u620f\u670d\u52a1\u7aef\u5f00\u53d1\u5de5\u7a0b\u5e08","num":91},{"cate2":"UE4\u5f00\u53d1\u5de5\u7a0b\u5e08","num":64},{"cate2":"Cocos2d-x\u5f00\u53d1\u5de5\u7a0b\u5e08","num":62},{"cate2":"\u7535\u5b50\u7ade\u6280\u8fd0\u8425","num":54}],"\u7535\u5b50/\u7535\u5668/\u4eea\u5668\u4eea\u8868":[{"cate2":"\u7535\u5b50\u9500\u552e\u5de5\u7a0b\u5e08","num":31373},{"cate2":"\u7535\u6c14\u5de5\u7a0b\u5e08/\u6280\u672f\u5458","num":25962},{"cate2":"\u7535\u5b50\u5de5\u827a\u5de5\u7a0b\u5e08","num":17799},{"cate2":"\u7535\u5b50\u5de5\u7a0b\u5e08/\u6280\u672f\u5458","num":7240},{"cate2":"\u786c\u4ef6\u5de5\u7a0b\u5e08","num":5093},{"cate2":"\u81ea\u52a8\u63a7\u5236\u5de5\u7a0b\u5e08/\u6280\u672f\u5458","num":4109},{"cate2":"\u5d4c\u5165\u5f0f\u8f6f\u4ef6\u5f00\u53d1(Linux/\u5355\u7247\u673a/PLC/DSP\u2026)","num":3166},{"cate2":"\u7535\u5b50\u6280\u672f\u7814\u53d1\u5de5\u7a0b\u5e08","num":3130},{"cate2":"\u7535\u5b50\u5143\u5668\u4ef6\u5de5\u7a0b\u5e08","num":2020},{"cate2":"\u7535\u5b50/\u7535\u5668\u7ef4\u4fee\u5de5\u7a0b\u5e08/\u6280\u5e08","num":1772},{"cate2":"\u7535\u5b50\u8f6f\u4ef6\u5f00\u53d1(ARM/MCU...)","num":1260},{"cate2":"\u4eea\u5668/\u4eea\u8868/\u8ba1\u91cf\u5206\u6790\u5e08","num":1227},{"cate2":"\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","num":686},{"cate2":"\u7535\u5b50\u8bbe\u5907\u5de5\u7a0b\u5e08","num":683},{"cate2":"\u5d4c\u5165\u5f0f\u786c\u4ef6\u5f00\u53d1(\u4e3b\u677f\u673a\u2026)","num":514},{"cate2":"\u6fc0\u5149/\u5149\u7535\u5b50\u6280\u672f","num":386},{"cate2":"\u7535\u8def\u5de5\u7a0b\u5e08/\u6280\u672f\u5458(\u6a21\u62df/\u6570\u5b57)","num":337},{"cate2":"\u7535\u6c60/\u7535\u6e90\u5f00\u53d1","num":221},{"cate2":"\u786c\u4ef6\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":143},{"cate2":"\u5bb6\u7528\u7535\u5668/\u6570\u7801\u4ea7\u54c1\u7814\u53d1","num":91},{"cate2":"\u5b89\u9632\u7cfb\u7edf\u5de5\u7a0b\u5e08","num":49},{"cate2":"\u7535\u58f0/\u97f3\u54cd\u5de5\u7a0b\u5e08/\u6280\u672f\u5458","num":34}],"\u79fb\u52a8\u5f00\u53d1":[{"cate2":"Android\u5f00\u53d1\u5de5\u7a0b\u5e08","num":2222},{"cate2":"\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u5de5\u7a0b\u5e08","num":1529},{"cate2":"\u79fb\u52a8\u5f00\u53d1\u5de5\u7a0b\u5e08","num":1376},{"cate2":"iOS\u5f00\u53d1\u5de5\u7a0b\u5e08","num":580}],"\u8bbe\u8ba1":[{"cate2":"\u7f51\u9875\u8bbe\u8ba1\u5e08","num":11209},{"cate2":"\u4ea4\u4e92\u8bbe\u8ba1\u5e08","num":4925},{"cate2":"UI\u8bbe\u8ba1\u5e08","num":4718},{"cate2":"\u89c6\u89c9\u8bbe\u8ba1\u5e08","num":2542},{"cate2":"\u7528\u6237\u4f53\u9a8c\uff08UE/UX\uff09\u8bbe\u8ba1\u5e08","num":395},{"cate2":"\u4eff\u771f\u5e94\u7528\u5de5\u7a0b\u5e08","num":243},{"cate2":"\u7279\u6548\u8bbe\u8ba1\u5e08","num":38}],"\u8fd0\u7ef4/\u6280\u672f\u652f\u6301":[{"cate2":"\u8fd0\u7ef4\u5de5\u7a0b\u5e08","num":54848},{"cate2":"\u6280\u672f\u652f\u6301/\u7ef4\u62a4\u5de5\u7a0b\u5e08","num":27849},{"cate2":"ERP\u5b9e\u65bd\u987e\u95ee","num":7021},{"cate2":"\u7cfb\u7edf\u5de5\u7a0b\u5e08","num":5962},{"cate2":"\u7f51\u7edc\u5de5\u7a0b\u5e08(IT\u5de5\u7a0b\u5e08)","num":5570},{"cate2":"\u81ea\u52a8\u5316\u8fd0\u7ef4\u5de5\u7a0b\u5e08","num":3765},{"cate2":"\u6570\u636e\u5e93\u5de5\u7a0b\u5e08(DBA)","num":3475},{"cate2":"\u7f51\u7edc\u7ba1\u7406(Helpdesk)","num":2998},{"cate2":"\u6280\u672f\u652f\u6301/\u7ef4\u62a4\u7ecf\u7406","num":2748},{"cate2":"\u8fd0\u7ef4\u5f00\u53d1","num":2117},{"cate2":"\u7cfb\u7edf\u96c6\u6210\u5de5\u7a0b\u5e08","num":1736},{"cate2":"IT\u7ecf\u7406/IT\u4e3b\u7ba1","num":1601},{"cate2":"\u7f51\u7edc\u5b89\u5168\u5de5\u7a0b\u5e08","num":1061},{"cate2":"\u7f51\u7edc\u7ef4\u4fee","num":349},{"cate2":"\u7f51\u7ad9\u7ef4\u62a4\u5de5\u7a0b\u5e08","num":93},{"cate2":"\u7535\u8111\u7ef4\u4fee","num":52}],"\u901a\u4fe1\u6280\u672f\u5f00\u53d1\u53ca\u5e94\u7528":[{"cate2":"\u901a\u4fe1\u9500\u552e\u5de5\u7a0b\u5e08","num":7259},{"cate2":"\u901a\u4fe1\u9879\u76ee\u7ba1\u7406","num":6508},{"cate2":"\u901a\u4fe1\u6280\u672f\u5de5\u7a0b\u5e08","num":4131},{"cate2":"\u901a\u4fe1\u6587\u6863\u5de5\u7a0b\u5e08","num":3408},{"cate2":"\u901a\u4fe1\u8bbe\u5907\u5de5\u7a0b\u5e08","num":1323},{"cate2":"\u65e0\u7ebf\u901a\u4fe1\u5de5\u7a0b\u5e08","num":1158},{"cate2":"\u57fa\u7ad9\u5de5\u7a0b\u5e08","num":791},{"cate2":"\u5c04\u9891\u5de5\u7a0b\u5e08","num":225},{"cate2":"\u901a\u4fe1\u6d4b\u8bd5\u5de5\u7a0b\u5e08","num":217},{"cate2":"\u5149\u901a\u4fe1\u5de5\u7a0b\u5e08","num":132},{"cate2":"\u6570\u636e\u901a\u4fe1\u5de5\u7a0b\u5e08","num":68},{"cate2":"\u901a\u4fe1\u7f51\u7edc\u5de5\u7a0b\u5e08","num":65}]}})

#全国行业人才需求排行
@ind.route('/hyrc_num')
def hyrc_num():
    result = db.session.execute("select * from(select cate1,sum(num) as num from job group by cate1)job order by num DESC limit 10").fetchall()
    hyrc=[]
    num=[]
    for i in range(len(result)):
        hyrc.append(result[i][0])
        num.append(int(result[i][1]))
    return jsonify({
        "hyrc":hyrc,
        "num":num
    })

#城市行业人才需求排行POST
@ind.route('/hyrc_num1',methods=['POST'])
def hyrc_num1():
    postdata = request.form['name']
    result = db.session.execute("select cate1,sum(num) as num from job where city=\""+postdata+"\"  group by cate1 order by num desc limit 10;").fetchall()
    hyrc=[]
    num=[]
    for i in range(len(result)):
        hyrc.append(result[i][0])
        num.append(int(result[i][1]))
    return jsonify({
        "hyrc":hyrc,
        "num":num
    })

#省份行业人才需求排行POST
@ind.route('/province_hyrc_num1',methods=['POST'])
def province_hyrc_num1():
    postdata = request.form['name']
    result = db.session.execute("select cate1,sum(num) as num from job where province=\""+postdata+"\"  group by cate1 order by num desc limit 10;").fetchall()
    hyrc=[]
    num=[]
    for i in range(len(result)):
        hyrc.append(result[i][0])
        num.append(int(result[i][1]))
    return jsonify({
        "hyrc":hyrc,
        "num":num
    })

#全国岗位人才需求排行
@ind.route('/gwrc_num')
def gwrc_num():
    result = db.session.execute("select * from(select cate2,sum(num) as num from job group by cate2)job order by num DESC limit 11").fetchall()
    gwrc=[]
    num=[]
    for i in result:
        if (i[0] == "其他"):
            pass
        else:
            gwrc.append(i[0])
            num.append(int(i[1]))
    return jsonify({
        "gwrc":gwrc,
        "num":num
    })

#城市岗位人才需求排行POST
@ind.route('/gwrc_num1',methods=['POST'])
def gwrc_num1():
    postdata = request.form['name']
    result = db.session.execute("select cate2,sum(num) as num from job where city=\""+postdata+"\"  group by cate2 order by num desc limit 10;").fetchall()
    # result = result.limit(10).all()
    gwrc=[]
    num=[]
    for i in result:
        if (i[0] == "其他"):
            pass
        else:
            gwrc.append(i[0])
            num.append(int(i[1]))
    return jsonify({
        "gwrc":gwrc,
        "num":num,
    })

#省份岗位人才需求排行POST
@ind.route('/province_gwrc_num1',methods=['POST'])
def province_gwrc_num1():
    postdata = request.form['name']
    result = db.session.execute("select cate2,sum(num) as num from job where province=\""+postdata+"\"  group by cate2 order by num desc limit 10;").fetchall()
    # result = result.limit(10).all()
    gwrc=[]
    num=[]
    for i in result:
        if (i[0] == "其他"):
            pass
        else:
            gwrc.append(i[0])
            num.append(int(i[1]))
    return jsonify({
        "gwrc":gwrc,
        "num":num,
    })

#岗位 城市 平均工资
@ind.route('/gw_city_sal')
def gw_city_sal():
    # result = db.session.execute(
    #     "select * from(select cate2,city,avg(salary)as avg_sal,sum(num) from job group by cate2,city)job order by avg_sal DESC limit 200").fetchall()
    # gw=[]
    # city=[]
    # sal=[]
    # jobsum=0
    # for i in result:
    #     if (i[0] == "其他"):
    #         pass
    #     else:
    #         gw.append(i[0])
    #         city.append(i[1])
    #         sal.append(int(i[2]))
    #         jobsum += i[3]
    # return jsonify({
    #     "gw":gw,
    #     "city":city,
    #     "sal":sal
    # })
    return jsonify({"city":["\u5357\u901a","\u4f5b\u5c71","\u6606\u660e","\u53a6\u95e8","\u4e1c\u839e","\u798f\u5dde","\u829c\u6e56","\u53a6\u95e8","\u6e29\u5dde","\u6e56\u5dde","\u5609\u5174","\u5357\u4eac","\u5e38\u719f","\u6e56\u5dde","\u5317\u4eac","\u90d1\u5dde","\u73e0\u6d77","\u5f90\u5dde","\u6b66\u6c49","\u4f5b\u5c71","\u6cc9\u5dde","\u4f5b\u5c71","\u5317\u4eac","\u7ef5\u9633","\u798f\u5dde","\u5317\u4eac","\u82cf\u5dde","\u53f0\u5dde","\u6d4e\u5357","\u897f\u5b89","\u676d\u5dde","\u5357\u901a","\u4e0a\u6d77","\u5317\u4eac","\u5317\u4eac","\u5e38\u5dde","\u6c5f\u95e8","\u4e0a\u6d77","\u6c88\u9633","\u4e0a\u6d77","\u4e0a\u6d77","\u4f5b\u5c71","\u4e0a\u6d77","\u5927\u8fde","\u5317\u4eac","\u5927\u8fde","\u5317\u4eac","\u5e7f\u5dde","\u5e7f\u5dde","\u6e29\u5dde","\u73e0\u6d77","\u6cf0\u5dde","\u4e1c\u839e","\u6dee\u5b89","\u6e29\u5dde","\u6df1\u5733","\u6df1\u5733","\u53a6\u95e8","\u5929\u6d25","\u6210\u90fd","\u5f20\u5bb6\u6e2f","\u6210\u90fd","\u8087\u5e86","\u6cc9\u5dde","\u626c\u5dde","\u6cf0\u5dde","\u957f\u6c99","\u53a6\u95e8","\u4f5b\u5c71","\u6e29\u5dde","\u5609\u5174","\u5317\u4eac","\u5357\u901a","\u5e38\u5dde","\u6df1\u5733","\u6df1\u5733","\u4e0a\u6d77","\u5317\u4eac","\u5317\u4eac","\u4e0a\u6d77","\u4e0a\u6d77","\u4f5b\u5c71","\u676d\u5dde","\u6df1\u5733","\u676d\u5dde","\u5609\u5174","\u5357\u660c","\u897f\u5b89","\u76d0\u57ce","\u9752\u5c9b","\u4f5b\u5c71","\u5317\u4eac","\u4e1c\u839e","\u5317\u4eac","\u5e38\u719f","\u676d\u5dde","\u7ecd\u5174","\u6cc9\u5dde","\u5357\u4eac","\u676d\u5dde","\u4f5b\u5c71","\u5357\u4eac","\u5317\u4eac","\u4e1c\u839e","\u5357\u5b81","\u9547\u6c5f","\u6e56\u5dde","\u5e38\u5dde","\u4e2d\u5c71","\u6e56\u5dde","\u73e0\u6d77","\u82cf\u5dde","\u897f\u5b89","\u957f\u6c99","\u5927\u8fde","\u5b81\u6ce2","\u5609\u5174","\u592a\u4ed3","\u9547\u6c5f","\u6df1\u5733","\u53f0\u5dde","\u4e2d\u5c71","\u5317\u4eac","\u91d1\u534e","\u82cf\u5dde","\u82cf\u5dde","\u5317\u4eac","\u6df1\u5733","\u76d0\u57ce","\u4e0a\u6d77","\u5e7f\u5dde","\u6c88\u9633","\u5317\u4eac","\u5317\u4eac","\u4e0a\u6d77","\u6e29\u5dde","\u4e0a\u6d77","\u6df1\u5733","\u60e0\u5dde","\u5317\u4eac","\u897f\u5b89","\u5357\u4eac","\u676d\u5dde","\u5e7f\u5dde","\u90d1\u5dde","\u4e1c\u839e","\u8d35\u9633","\u6df1\u5733","\u4f5b\u5c71","\u90d1\u5dde","\u6df1\u5733","\u82cf\u5dde","\u5317\u4eac","\u5317\u4eac","\u676d\u5dde","\u4e0a\u6d77","\u4e0a\u6d77","\u5e7f\u5dde","\u4e0a\u6d77","\u4f5b\u5c71","\u9752\u5c9b","\u53f0\u5dde","\u5317\u4eac","\u5408\u80a5","\u6606\u5c71","\u4e2d\u5c71","\u5357\u4eac","\u5927\u8fde","\u65e0\u9521","\u91cd\u5e86","\u53a6\u95e8","\u5b81\u6ce2","\u4e0a\u6d77","\u676d\u5dde","\u4e0a\u6d77","\u5408\u80a5","\u6e05\u8fdc","\u5609\u5174","\u626c\u5dde","\u4e0a\u6d77","\u6210\u90fd","\u676d\u5dde","\u5317\u4eac","\u73e0\u6d77","\u592a\u4ed3","\u5357\u4eac","\u5317\u4eac","\u592a\u4ed3","\u6606\u5c71","\u6df1\u5733","\u5e38\u719f","\u60e0\u5dde","\u6210\u90fd","\u65e0\u9521","\u4e0a\u6d77","\u5317\u4eac","\u6df1\u5733","\u6210\u90fd","\u4e2d\u5c71","\u676d\u5dde"],"gw":["Python\u5f00\u53d1\u5de5\u7a0b\u5e08","\u722c\u866b\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6d4b\u8bd5\u603b\u76d1","\u81ea\u52a8\u5316\u6d4b\u8bd5","\u6a21\u62df\u82af\u7247\u5de5\u7a0b\u5e08","\u7535\u5b50\u6280\u672f\u7814\u53d1\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u4ea7\u54c1\u603b\u76d1","\u4ea7\u54c1\u603b\u76d1","\u4ea7\u54c1\u603b\u76d1","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","Hadoop\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","iOS\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u5bb6\u7528\u7535\u5668/\u6570\u7801\u4ea7\u54c1\u7814\u53d1","\u5c01\u88c5\u7814\u53d1\u5de5\u7a0b\u5e08","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u9879\u76ee\u4e3b\u7ba1","\u6570\u636e\u5efa\u6a21\u5de5\u7a0b\u5e08","\u591a\u5a92\u4f53\u5f00\u53d1\u5de5\u7a0b\u5e08","\u7535\u5b50\u9500\u552e\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u9879\u76ee\u603b\u76d1","\u6570\u5b57\u524d\u7aef\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u5931\u6548\u5206\u6790\u5de5\u7a0b\u5e08(FA)","\u9879\u76ee\u7ecf\u7406","\u9996\u5e2d\u6280\u672f\u6267\u884c\u5b98CTO/\u9996\u5e2d\u4fe1\u606f\u5b98CIO","\u7cfb\u7edf\u5206\u6790\u5458","\u56fe\u50cf\u5904\u7406\u5de5\u7a0b\u5e08","\u9879\u76ee\u603b\u76d1","\u4ea7\u54c1\u603b\u76d1","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u7cfb\u7edf\u5206\u6790\u5458","\u56fe\u50cf\u5904\u7406\u5de5\u7a0b\u5e08","\u4ea7\u54c1\u603b\u76d1","\u4ea7\u54c1\u603b\u76d1","\u9ad8\u7ea7\u8f6f\u4ef6\u5de5\u7a0b\u5e08","C/C++\u5f00\u53d1\u5de5\u7a0b\u5e08","\u673a\u5668\u5b66\u4e60\u5de5\u7a0b\u5e08","\u79fb\u52a8\u5f00\u53d1\u5de5\u7a0b\u5e08","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u56fe\u50cf\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u4ea7\u54c1\u603b\u76d1","Ruby\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6fc0\u5149/\u5149\u7535\u5b50\u6280\u672f","\u7535\u6c60/\u7535\u6e90\u5f00\u53d1","\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","\u7535\u5b50\u9500\u552e\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u4ea7\u54c1\u603b\u76d1","Cocos2d-x\u5f00\u53d1\u5de5\u7a0b\u5e08","\u56fe\u50cf\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u4eea\u5668/\u4eea\u8868/\u8ba1\u91cf\u5206\u6790\u5e08","IC\u9a8c\u8bc1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","EDA\u5de5\u7a0b\u5e08","\u7535\u6c60/\u7535\u6e90\u5f00\u53d1","\u673a\u5668\u89c6\u89c9\u5de5\u7a0b\u5e08","\u641c\u7d22\u7b97\u6cd5\u5de5\u7a0b\u5e08","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u96c6\u6210\u5de5\u7a0b\u5e08","\u6d4b\u8bd5\u603b\u76d1","EDA\u5de5\u7a0b\u5e08","\u641c\u7d22\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u4ea7\u54c1\u603b\u76d1","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u56fe\u50cf\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u6e38\u620f\u5ba2\u6237\u7aef\u5f00\u53d1\u5de5\u7a0b\u5e08","IC\u9a8c\u8bc1\u5de5\u7a0b\u5e08","\u9879\u76ee\u603b\u76d1","\u5bb6\u7528\u7535\u5668/\u6570\u7801\u4ea7\u54c1\u7814\u53d1","\u4ea7\u54c1\u603b\u76d1","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u4eff\u771f\u5e94\u7528\u5de5\u7a0b\u5e08","\u6807\u51c6\u5316\u5de5\u7a0b\u5e08","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6e38\u620f\u7279\u6548\u8bbe\u8ba1\u5e08","\u5d4c\u5165\u5f0f\u8f6f\u4ef6\u5f00\u53d1(Linux/\u5355\u7247\u673a/PLC/DSP\u2026)","\u6e38\u620f\u7cfb\u7edf\u7b56\u5212","\u79fb\u52a8\u4ea7\u54c1\u7ecf\u7406","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","Python\u5f00\u53d1\u5de5\u7a0b\u5e08","\u641c\u7d22\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u9879\u76ee\u7ecf\u7406","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6d4b\u8bd5\u603b\u76d1","IC\u9a8c\u8bc1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u9879\u76ee\u603b\u76d1","\u5c04\u9891\u82af\u7247\u8bbe\u8ba1","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","\u8fd0\u7ef4\u5f00\u53d1","\u534a\u5bfc\u4f53\u6587\u6863\u5de5\u7a0b\u5e08","\u6a21\u62df\u82af\u7247\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u5206\u6790\u5458","\u57fa\u7ad9\u5de5\u7a0b\u5e08","\u5d4c\u5165\u5f0f\u8f6f\u4ef6\u5f00\u53d1(Linux/\u5355\u7247\u673a/PLC/DSP\u2026)","\u79fb\u52a8\u4ea7\u54c1\u7ecf\u7406","\u6570\u636e\u5efa\u6a21\u5de5\u7a0b\u5e08","\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u4ea7\u54c1\u603b\u76d1","\u5c04\u9891\u82af\u7247\u8bbe\u8ba1","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u79fb\u52a8\u5f00\u53d1\u5de5\u7a0b\u5e08","\u7535\u5b50\u8f6f\u4ef6\u5f00\u53d1(ARM/MCU...)","\u5bb6\u7528\u7535\u5668/\u6570\u7801\u4ea7\u54c1\u7814\u53d1","\u4e92\u8054\u7f51\u4ea7\u54c1\u7ecf\u7406","\u7535\u5b50\u9500\u552e\u5de5\u7a0b\u5e08","EDA\u5de5\u7a0b\u5e08","\u7528\u6237\u4f53\u9a8c\uff08UE/UX\uff09\u8bbe\u8ba1\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u591a\u5a92\u4f53\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u96c6\u6210\u7535\u8defIC\u8bbe\u8ba1/\u5e94\u7528\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u6570\u636e\u5efa\u6a21\u5de5\u7a0b\u5e08","\u96c6\u6210\u7535\u8defIC\u8bbe\u8ba1/\u5e94\u7528\u5de5\u7a0b\u5e08","\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","\u63a8\u8350\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6570\u636e\u5206\u6790\u5e08","\u5c04\u9891\u82af\u7247\u8bbe\u8ba1","\u9879\u76ee\u603b\u76d1","Android\u5f00\u53d1\u5de5\u7a0b\u5e08","\u79fb\u52a8\u5f00\u53d1\u5de5\u7a0b\u5e08","\u82af\u7247\u6d4b\u8bd5\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u6e38\u620f\u7279\u6548\u8bbe\u8ba1\u5e08","\u9879\u76ee\u603b\u76d1","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6e38\u620f\u52a8\u4f5c\u8bbe\u8ba1\u5e08","Hadoop\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","Hadoop\u5de5\u7a0b\u5e08","\u6570\u636e\u5efa\u6a21\u5de5\u7a0b\u5e08","\u6570\u636e\u4ed3\u5e93\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u6570\u5b57\u524d\u7aef\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u591a\u5a92\u4f53\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","EDA\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","Python\u5f00\u53d1\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","\u6a21\u62df\u7248\u56fe\u5de5\u7a0b\u5e08","\u673a\u5668\u89c6\u89c9\u5de5\u7a0b\u5e08","\u534a\u5bfc\u4f53\u4ea7\u54c1\u7ecf\u7406/\u4ea7\u54c1\u5de5\u7a0b\u5e08","Ruby\u5f00\u53d1\u5de5\u7a0b\u5e08","\u4ea7\u54c1\u603b\u76d1","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","\u4ea7\u54c1\u603b\u76d1","\u6e38\u620f\u539f\u753b\u5e08","\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","\u56fe\u50cf\u7b97\u6cd5\u5de5\u7a0b\u5e08","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6d4b\u8bd5\u603b\u76d1","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u4e92\u8054\u7f51\u4ea7\u54c1\u7ecf\u7406","Hadoop\u5de5\u7a0b\u5e08","\u7cfb\u7edf\u67b6\u6784\u8bbe\u8ba1\u5e08","Hadoop\u5de5\u7a0b\u5e08","\u7528\u6237\u4f53\u9a8c\uff08UE/UX\uff09\u8bbe\u8ba1\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","Java\u5f00\u53d1\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u722c\u866b\u5f00\u53d1\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u8f6f\u4ef6\u5de5\u7a0b\u5e08","\u7535\u6c60/\u7535\u6e90\u5f00\u53d1","Go\u5f00\u53d1\u5de5\u7a0b\u5e08","\u7b97\u6cd5\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u786c\u4ef6\u5de5\u7a0b\u5e08","\u82af\u7247\u67b6\u6784\u5de5\u7a0b\u5e08","\u6280\u672f\u603b\u76d1/\u7ecf\u7406","\u6e38\u620f\u5f00\u53d1\u5de5\u7a0b\u5e08","Ruby\u5f00\u53d1\u5de5\u7a0b\u5e08","\u9ad8\u7ea7\u8f6f\u4ef6\u5de5\u7a0b\u5e08","Python\u5f00\u53d1\u5de5\u7a0b\u5e08","\u8fd0\u7ef4\u5f00\u53d1","\u6e38\u620f\u52a8\u4f5c\u8bbe\u8ba1\u5e08"],"sal":[105000,84666,83333,70900,60000,56666,51666,50000,45833,45833,45833,45000,44722,41638,40000,40000,39166,37500,37500,37500,37500,37500,36961,36500,36333,36000,35416,35000,35000,35000,34419,34419,34375,34000,33750,33333,33055,32791,32500,32317,32244,31944,31563,31500,31500,31500,31451,31306,31299,31250,31250,31250,31100,30950,30625,30306,30000,30000,30000,30000,29722,29166,29166,29166,29166,29166,29166,29166,29166,29166,29083,29020,28729,28678,28634,28330,28144,28133,28064,27899,27873,27774,27718,27647,27500,27500,27500,27500,27500,27500,27500,26757,26555,26273,25875,25855,25833,25833,25618,25506,25305,25300,25253,25148,25083,25000,25000,25000,25000,25000,25000,25000,25000,25000,25000,24768,24500,24500,24375,24300,24166,24150,24085,24022,24022,24000,23994,23840,23809,23735,23501,23500,23495,23418,23356,23231,23162,23141,23100,23095,23093,23091,23035,23020,23000,23000,23000,22887,22871,22833,22822,22813,22812,22764,22763,22720,22677,22641,22633,22542,22500,22500,22500,22500,22500,22500,22500,22500,22500,22500,22500,22500,22428,22371,22305,22233,22166,22138,22111,22043,22029,21981,21964,21916,21800,21775,21750,21742,21722,21676,21666,21666,21647,21643,21571,21565,21508,21500,21500,21500]})

#岗位 城市 平均工资POST
@ind.route('/gw_city_sal1',methods=['POST'])
def gw_city_sal1():
    postdata = request.form['name']
    result = db.session.execute(
        "select * from(select cate2,city,avg(salary)as avg_sal from job where city=\""+postdata+"\" group by cate2,city)job order by avg_sal DESC limit 500").fetchall()
    gw=[]
    city=[]
    sal=[]
    for i in result:
        if (i[0] == "其他"):
            pass
        else:
            gw.append(i[0])
            city.append(i[1])
            sal.append(int(i[2]))
    return jsonify({
        "gw":gw,
        "city":city,
        "sal":sal
    })

#省份岗位 城市 平均工资POST
@ind.route('/province_gw_city_sal1',methods=['POST'])
def province_gw_city_sal1():
    postdata = request.form['name']
    result = db.session.execute(
        "select * from(select cate2,province,avg(salary)as avg_sal from job where province=\""+postdata+"\" group by cate2,province)job order by avg_sal DESC limit 500").fetchall()
    gw=[]
    city=[]
    sal=[]
    for i in result:
        if (i[0] == "其他"):
            pass
        else:
            gw.append(i[0])
            city.append(i[1])
            sal.append(int(i[2]))
    return jsonify({
        "gw":gw,
        "city":city,
        "sal":sal
    })

@ind.route("/jobsum",methods=['post'])
def jobsum():
    city = request.form['city']
    province = request.form['province']
    if(city == ""):
        print("进入省份")
        result = db.session.execute("select sum(num) from job where province=\""+province+"\" group by province").fetchall()
    else:
        print("进入城市")
        result = db.session.execute("select sum(num) from job where city=\""+city+"\" group by city").fetchall()
    jobsum=0
    for i in result:
        jobsum=int(i[0])
    return jsonify({
        "jobsum":jobsum,
    })


# 查询所有分类
@ind.route('/cates_num1',methods=['post'])
def cates_num1():
    city = request.form['city']
    province = request.form['province']
    if(city == ""):
        result = db.session.execute(" select cate1,cate2,sum(num) num from job where province=\""+province+"\" group by cate1,cate2 order by cate1 ,num desc;")
    else:
        result = db.session.execute(" select cate1,cate2,sum(num) num from job where city=\""+city+"\" group by cate1,cate2 order by cate1 ,num desc;")
    '''
mysql> select cate1,cate2,sum(num) num from job group by cate1,cate2 order by cate1,num;
+--------------------+----------------------------------------+--------+
| cate1              | cate2                                  | num    |
+--------------------+----------------------------------------+--------+
| 产品               | 用户产品经理                           |      5 |
| 产品               | 移动产品经理                           |     98 |
| 产品               | 产品总监                               |    288 |
    '''
    result = result.fetchall()
    cates = {}

    cates = {}
    # 一级分类个数
    cate2_default = []
    for row in result:
        cate1 = row['cate1']
        cate2 = row['cate2']
        num = int(row['num'])

        # 跳过其他
        if cate2 == "其他":
            continue

        # 有就直接接
        if cate1 not in cates.keys():
            cates[cate1] = []

        cates[cate1].append({
            'cate2': cate2,
            'num': num
        })
        cate2_default.append({
            "cate2": cate2,
            "num": num
        })

    # 一级分类数量
    cate1_num = []
    for cate1, cate2 in cates.items():
        s = 0
        for item in cate2:
            s += item['num']
        cate1_num.append({
            "cate1": cate1,
            "num": s
        })
    # 二级分类top10
    cate2_default.sort(key=lambda x: x['num'], reverse=True)
    cate2_default = cate2_default[0:11]

    cate1_num.sort(key=lambda k: k['num'], reverse=True)
    # print(cates)
    # print(cate2_default)
    # print(cate1_num)
    # 二级分类默认显示Top 的
    cates['全部'] = cate2_default
    data = {
        'cate2_num': cates,
        'cate1_num': cate1_num
    }
    return jsonify(data)



# 测试
@ind.route('main')
def main():
    
    return render_template('ind2.html')


@ind.route('report')
def report():
    return render_template('report.html')